#!/bin/bash
# Program:
#	Use ping command to check the network's PC state.
# History:
#	2014/03/19  Sunny  First release
#
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/local/sbin:~/bin
export PATH

network="192.168.1"	# 先定义一个网域的前面一部分

for sitenu in $(seq 1 255)	# seq为sequence(连续)的缩写
do 
	# 底下是程序在取得ping的回传值是正确还是失败
	result=$(ping -c 1 -w 1 ${network}.${sitenu} | grep "ttl")
	# 开始显示结果是正确的启动(UP)还是错误的没有联通(DOWN)
	if [ "$result" != "" ]; then
		echo "Service ${network}.${sitenu} is UP."
	#else
	#	echo "Service ${network}.${sitenu} is DOWN."
	fi
done
